<template>
	<view>
		<TopHead :title="'我的任务	'" :fhShow="flasa"></TopHead>
		<view class="tabbar-box">
			<view class="bar-item" :class="indxId==item.id?'barActive':''" v-for="(item,index) in barList" :key="index"
				@click="choose(item.id)">
				<text>{{item.title}}</text>
				<text> </text>
			</view>
		</view>
		<view class="conbox">
			<view class="list">
				<view class="itemBox" v-for="(item,index) in listData" :key="index" @click="handleClick(item)">
				<view><view>{{item.title}}</view>
					<view>{{item.taskDate}}</view></view>
				<view><view>{{getStatus(item.status)}}</view></view>
					
					
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import TopHead from '../../components/topHead/topHead.vue';
	export default {
		components: {
			TopHead
		},
		data() {
			return {
				barList: [{
						title: '新任务',
						id: 0
					},
					{
						title: '进行中',
						id: 1
					},
					{
						title: '已完成',
						id: 2
					},
					{
						title: '全部',
						id: 3
					},

				],
				indxId: 0, // 
				list: [
					// {title:'新任务',id:0},
					// {title:'陪诊业务',id:0},
					// {title:'配送业务',id:0},
					// {title:'审核',id:0},
				],
				listData: [],
				userInfo: {}
			}
		},
		onLoad() {

		},
		onShow() {
			this.userInfo = JSON.parse(uni.getStorageSync('user_info'));
			console.log("userInfo", this.userInfo);
			this.initData("")
		},
		onReachBottom() {
			// 触底分页
			console.log('触底')
			// if (this.total > this.list.length) {
			// 	this.page = parseInt(this.page) + 1
			// }
		},
		methods: {
			handleClick(row) {
				console.log("row====>", row);
				var productType = row.info.productEntity.productType;
				if (productType == 1) {
					console.log("productType", productType)
					uni.navigateTo({
						url: `/pages_category_page1/mine/delivery?taskId=` + row.id
					})
				}

				if (productType == 2) {
					uni.navigateTo({
						url: `/pages_category_page1/mine/nursing?taskId=` + row.id
					})
				}
				if (productType == 3) {
					uni.navigateTo({
						url: `/pages_category_page1/mine/nursing?taskId=` + row.id
					})
				}
			},
			getStatus(val) {
				var txt = "";

				if (val == 9) {
					txt = "未开始"
				}
				if (val == 10) {
					txt = "服务中"
				}if (val == 11) {
					txt = "服务中"
				}
				if (val == 3) {
					txt = "服务结束"
				}
				return txt;
			},
			// 数据请求示例
			initData(status) {
				let _this = this;
				var data = {
					userId: _this.userInfo.id,
					status: status
				}
				_this.$http.fetchData({
					url: '/wechatApplet/worker/jobTask/',
					method: 'GET',
					data: data,
					success(res) {
						if (res.code != 200) {
							uni.showToast({
								title: res.msg,
								icon: 'none'
							});
							return
						}

						//_this.list = [..._this.list, ...res.data]
						this.total = res.total
						_this.listData = res.data.list
						console.log("listData", _this.listData)
						// if (res.total == 1) {
						// 	let id = listData[0].id
						// 	let total = this.total
						// 	let paramsStr = `?biaoduan_id=${id}&biaoduanTotal=${total}`
						// 	uni.redirectTo({
						// 		url: `/pages/procedureList/procedureList${paramsStr}`
						// 	})
						// }
					}
				})
			},
			 
			// 取消订单
			cancelOrder(item) {
				console.log(item)
			},
			// 去付款
			goPay(item) {
				console.log(item)
			},
			choose(id) {
				console.log(id)
				this.indxId = id
				var status = "";
				if (id == 0) {
					status = 9
				}
				if (id == 1) {
					status = 10
				}
				if (id == 2) {
					status = 3
				}

				this.initData(status);
			},


		}
	}
</script>

<style scoped>
	.headBox {
		font-size: 36rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Bold;
		font-weight: 700;
		text-align: center;
		color: #232323;
		padding-top: 88rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
		padding-bottom: 112rpx;
		background: linear-gradient(89deg, #f9d7a6 1%, #ffdc95 100%);
	}

	.headBox .wzText {
		line-height: 56rpx;
	}

	.tabbar-box {
		padding: 30rpx;
		background: #f3f3f3;
		display: flex;
		position: fixed;
		top: 173rpx;
		left: 0;
		right: 0;
		z-index: 99;
	}

	.bar-item {
		font-size: 28rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Regular;
		font-weight: 400;
		color: #000000;
		/* display: inline-block; */
		margin-right: 34rpx;
		text-align: center;
		flex: 1;
	}

	.tabbar-box .bar-item:last-child {
		margin-right: 0;
	}

	.bar-item>text:nth-child(1) {}

	.bar-item>text:nth-child(2) {
		width: 30%;
		height: 8rpx;
		display: block;
		margin: 0 auto;
		margin-top: 9rpx;
	}

	.tabbar-box .barActive {
		font-size: 28rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Bold;
		font-weight: 700;
		color: #e47917;
	}

	.tabbar-box .barActive>text:last-child {
		background: #e47917;
		border-radius: 4rpx;
	}

	.conbox {
		padding: 30rpx;
		padding-top: 290rpx;

	}

	.itemBox {
		border-bottom: 2rpx solid rgba(94, 94, 94, .1);
		display: flex;
		padding: 45rpx 0;
	}

	.itemBox>view:nth-child(1) {
		font-size: 28rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Bold;
		font-weight: 700;
		text-align: left;
		color: #5d4529;
		flex: 1;
	}
	.itemBox>view:nth-child(1)>view:nth-child(2) {
		font-size: 20rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Regular;
		font-weight: 400;
		color: #7e8898;
		flex: 1;
	}
	.itemBox>view:nth-child(2) {
		font-size: 28rpx;
		font-family: Microsoft YaHei, Microsoft YaHei-Regular;
		font-weight: 400;
		text-align: right;
		color: #7e8898;
		flex: 1;
	}
</style>